package com.nandi.deviceinstall.net

import com.nandi.deviceinstall.base.BaseView
import com.nandi.deviceinstall.net.exception.ExceptionHandle
import org.reactivestreams.Subscriber
import org.reactivestreams.Subscription

/*
    Rx订阅者默认实现
 */
open class BaseSubscriber<T>(val baseView: BaseView) : Subscriber<T> {
    override fun onComplete() {
        baseView.hideLoading()
    }

    override fun onSubscribe(s: Subscription?) {
    }

    override fun onNext(t: T) {
    }

    override fun onError(e: Throwable?) {
        baseView.hideLoading()

        baseView.onError(ExceptionHandle.handleException(e!!), ExceptionHandle.errorCode)
    }

}
